<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/13
 * Time: 15:50
 */

namespace core;


use core\exception\Exception;

class Model
{
    private $model;

    public function __construct()
    {
        $type = Config::getInstance()->getConfig('database.type');
        $model = ucfirst($type).'Model';
        if (!class_exists($model)){
            $model = 'core\\db\\'.$model;
        }
        $this->model = new $model(explode('\\',static::class)[count(explode('\\',static::class))-1]);
    }

    public function __call($name, $arguments)
    {
        if (is_callable([$this->model,$name])){
            return call_user_func_array([$this->model,$name],$arguments);
        }
        throw new Exception('无此方法');
    }
}